function changeSubCategory(){
	var category = document.getElementById('category_id');
	var sub_category = document.getElementById('sub_category_id')
	
	if (category.value == ''){
		return;
	}
	sub_category.options.length = 0;
	var counter = 0;
	for (var i = 0; i < sub_category_options.length; i++) {
		if (sub_category_options[i].category_id == category.value) {
			sub_category.options[counter] = new Option(sub_category_options[i].sub_category_name, sub_category_options[i].sub_category_id);
			counter++;
		}
	}
}

function checkAge(){
	var year = document.getElementById('age_year');
	var month = document.getElementById('age_month');
	
	if (year.value > 3){
		$("#age_month_label").hide();
		$("#age_month").hide();
	}
	else{
		$("#age_month_label").show();
		$("#age_month").show();
	}
	
	if (year.value == 0){
		month.options[0].text = "<1";
	}
	else{
		month.options[0].text = "0";
	}
} 
 
function changePrice(){
	if (document.getElementById('price_free').checked == true) {
		document.getElementById('item_price').value = 0;
	}
}

function changePriceSelector(){
	document.getElementById('price_free').checked = false;
	document.getElementById('price_cost').checked = true;
}
 
$(document).ready(function(){
	checkAge();
	changeSubCategory();
	//changePrice();
	//changePriceSelector();
	StarRating.init('star-rating', document.getElementById('item_condition'), 3, 5, '../resources/itemmanagement/offstar.gif', '../resources/itemmanagement/onstar.gif');
	StarRating.set('star-rating', item_condition - 1);
});